##*****************************************************************************
## FIGURE 1
##*****************************************************************************
## 
## R Version: R version 3.2.4 (2016-03-1)
##


##LOADING PACKAGES
library(ggplot2) ##Version: 2.1.0

##SET WORKING DIRECTORY
setwd('~/workspace/fed_courts/scaling_paper/')

##LOADING DATASET
dat <- read.csv('replication_materials/data/cand_vs_contrib_dime_scores.csv')



##PLOTTING PDF -- WITH TRANSPARENCY 
qq <- ggplot(data=dat,
             aes(x=dime.contrib.cfscore,y=dime.cand.cfscore,
                 colour=factor(cand.party),
                 label=substr(cand.party,1,1),
                 alpha=.7)) 
qq <- qq + geom_text(size = 3)
qq <- qq + scale_colour_manual('',values = c('D'="black",'R'="darkgrey",'I'='darkgrey'))
qq <- qq+xlim(-2,2)+ylim(-2,2)
qq <- qq + scale_alpha_continuous(guide=FALSE)
qq <- qq + xlab('Contributor DIME Score') + ylab('Candidate DIME Score')
qq <- qq + theme_bw()
qq <- qq + theme(legend.position='none')
qq

pdf('replication_materials/figures/figure_1_cand_cont_cfscore_plot.pdf',width = 10,height= 10)
print(qq)
dev.off()


##EPS -- WITHOUT TRANSPARENCY
qq <- ggplot(data=dat,
             aes(x=dime.contrib.cfscore,y=dime.cand.cfscore,
                 colour=factor(cand.party),
                 label=substr(cand.party,1,1)))
qq <- qq + geom_text(size = 3)
qq <- qq + scale_colour_manual('',values = c('D'="black",'R'="darkgrey",'I'='darkgrey'))
qq <- qq+xlim(-2,2)+ylim(-2,2)
qq <- qq + xlab('Contributor DIME Score') + ylab('Candidate DIME Score')
qq <- qq + theme_bw()
qq <- qq + theme(legend.position='none')
qq

setEPS()
postscript('replication_materials/figures/figure_1_cand_cont_cfscore_plot.eps',width = 10,height= 10)
print(qq)
dev.off()



